﻿using CommonBase;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Events;
using SurveillancePro.Base.Events;
using SurveillancePro.Base.ViewModels;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace ScreenMgtModule.ViewModels
{
    /// <summary>
    /// 画面选择
    /// </summary>
    public class ViewModel_SplitScreen : WorkspaceViewModel
    {
        #region Private Fields

        private DelegateCommand<string> _cmdSplitScreen;
        private readonly IEventAggregator _eventAggregator;

        #endregion

        #region Constructor

        public ViewModel_SplitScreen(IEventAggregator eventAggregator)
        {
            this._eventAggregator = eventAggregator;
        }

        #endregion

        #region Base Class Overrides

        protected override void OnDispose()
        {
        }

        #endregion

        #region Public Properties

        [Display(GroupName = "DelegateCommand")]
        public DelegateCommand<string> Cmd_SplitScreen
        {
            get
            {
                if (_cmdSplitScreen == null)
                {
                    _cmdSplitScreen = new DelegateCommand<string>(_splitScreen, _canSplitScreen);
                }
                return _cmdSplitScreen;
            }
        }

        #endregion

        #region Private Methods

        #region DelegateCommand

        private bool _canSplitScreen(string splitCount)
        {
            return true;
        }

        private void _splitScreen(string splitCount)
        {
            try
            {
                this._eventAggregator.GetEvent<OpenModelEvent>().Publish(new OpenModelEventArg() { ModelName = "ViewModel_Shell", FunctionName = "SplitScreen", Arg = splitCount, }); // 事件通知
            }
            catch (System.Exception ex)
            {
#if DEBUG
                Debug.WriteLine(ex.Message);
#endif
                MessageBox.Show(ex.Message, ConstantString.MSG_COMPANY);
            }
        }

        #endregion

        #endregion
    }
}
